//
//  JMLoadingView.h
//  JMLoadingView
//
//  Created by Matt Gallagher on 12/04/09.
//  Copyright Matt Gallagher 2009. All rights reserved.
// 
//  Permission is given to use this source code file, free of charge, in any
//  project, commercial or otherwise, entirely at your risk, with the condition
//  that any redistribution (in part or whole) of source code must retain
//  this copyright and permission notice. Attribution in compiled projects is
//  appreciated but not required.
//

#import <UIKit/UIKit.h>

#define LOADING_RECT_PADDING 35
#define LOADING_RECT_PADDING_PERCENT 0.08
#define LOADING_RECT_TEXT_PADDING 60
#define LOADING_RECT_TEXT_PADDING_PERCENT 0.12
#define LOADING_ROUND_RECT_CORNER_RADIUS 5.0
#define LOADING_BACKGROUND_OPACITY 0.7
#define LOADING_STROKE_OPACITY 0.25
#define GUI_FONT_SIZE_SMALL 14
typedef enum JMLoadingViewFlag {
	JMLoadingViewLoading,
	JMLoadingViewSuccessful,
	JMLoadingViewFailed	
} JMLoadingViewFlag;

@interface JMLoadingView : UIView
{
	UIActivityIndicatorView *activityIndicatorView;
	UIView * imageView;
	UILabel * textLabel;
	BOOL allowBackground;	
	
	UIView * superView;
	NSString * loadingText;
	NSString * successfulText;
	NSString * failText;
	JMLoadingViewFlag loadFlag;
}

@property (nonatomic, retain) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic, retain) UILabel * textLabel;
@property (nonatomic, retain) UIView * superView;
@property (nonatomic, retain) UIView * imageView;
@property (assign) BOOL allowBackground;
@property (assign) JMLoadingViewFlag loadFlag;
@property (nonatomic, retain) NSString * loadingText;
@property (nonatomic, retain) NSString * failText;
@property (nonatomic, retain) NSString * successfulText;

+ (id) loadingViewInView:(UIView *) aSuperview 
				WithText:(NSString*) text;

+ (id)loadingViewInView:(UIView *)superview_
			   WithText:(NSString*) loadingText_
			 FailedText:(NSString*) failText_
		   FinishedText:(NSString*) successfulText_;

- (id) initWithFrame:(CGRect) frame_ 
		 LoadingText:(NSString*) loadingText_ 
			FailText:(NSString*) failText_ 
	  SuccessfulText:(NSString*) successfulText_ 
	 AllowBackground:(BOOL) allowBackground_;

- (void) reload;
- (void)finishLoading;
- (void)finishLoadingWithText:(NSString*) text;
- (void)failLoading;
- (void)failLoadingWithText:(NSString*) text;
- (void)removeView;

@end
